import { Modal, Form, Input, Button } from "antd";
import React from "react";

function FormItem({ open, title, cancelFn, submitFn, form }) {
    const onFinish = (values) => {
        submitFn(values);
    }
    return (
        <Modal
            title={title} // 标题需要做成，活的
            open={open} // 是否打开弹框，活的
            footer={null}  // 清除底部按钮
            onCancel={() => {
                cancelFn();
            }}
        >
            <Form
                form={form}
                name="basic"
                labelCol={{ span: 5 }}
                wrapperCol={{ span: 16 }}
                style={{ maxWidth: 600 }}
                initialValues={{ remember: true }}
                onFinish={onFinish}
                autoComplete="off"
            >
                <Form.Item
                    label="ID"
                    name="id"
                    // hidden  隐藏这个字段
                >
                    <Input disabled />
                </Form.Item>
                <Form.Item
                    label="姓名"
                    name="name"
                    rules={[
                        {
                            required: true,
                            message: "Please input your username!",
                        },
                    ]}
                >
                    <Input.TextArea />
                </Form.Item>

                <Form.Item
                    label="岗位"
                    name="job"
                    rules={[
                        {
                            required: true,
                            message: "Please input your password!",
                        },
                    ]}
                >
                    <Input />
                </Form.Item>


                <Form.Item label={null}>
                    <Button type="primary" htmlType="submit">
                        提交
                    </Button>
                </Form.Item>
            </Form>
        </Modal>
    );
}

export default FormItem;
